package com.andlabs.gd.objects;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

/**
 * @author johannes
 */
public class LiveLine {
	//======================
	// Fields
	//======================
	public int mSpriteWidth;
	public int mSpriteHeight;
	//======================
	// MEMBERS
	//======================

	//======================
	// Constructors
	//======================
	public LiveLine(int spriteWidth, int spriteHeight){
		mSpriteWidth = spriteWidth;
		mSpriteHeight = spriteHeight;
	}
	
	//======================
	// Overridden Methods
	//======================

	//======================
	// Public Methods
	//======================
	public void render(Canvas canvas, float percentage, float x, float y){
		
		percentage = 1 - percentage;
		
		Paint paint = new Paint();
		paint.setColor(Color.GREEN);
		paint.setStrokeWidth(4);
		Paint borderPaint = new Paint();
		borderPaint.setColor(Color.BLACK);
	
		canvas.drawRect(x - 1, y - paint.getStrokeWidth() - 1, x + mSpriteWidth + 1, y + 1, borderPaint);
		
		canvas.drawLine(x, y - 2, (x + mSpriteWidth) - mSpriteWidth * percentage, y - 2, paint);
	
		if(percentage != 1){
			paint.setColor(Color.RED);
			canvas.drawLine((x + mSpriteWidth) - mSpriteWidth * percentage, (y) - 1, x + mSpriteWidth / 2, (y ) - 1, paint);
		}
	}
	//======================
	// Private Methods
	//======================
}

